﻿## This script using the Windows Azure AD Module, follow the link below to install it
## http://msdn.microsoft.com/en-us/library/azure/jj151815.aspx

Import-Module MSOnline
Import-Module MSOnlineExtended

# check to see if $cred exists, supports rerunning of the script without reprompting the user
# if you want to use new credentials then execute Remove-Variable cred
if (!(Test-Path variable:\cred)) {
    #prompt for credentials to connect to service
    $cred = Get-Credential
    Connect-MsolService -Credential $cred
}


#Uncomment the Set-MsolUser usage location if the user location has not been set, the applies to US users
Get-MsolUser –unlicensedusersonly –all #| Set-MsolUser –usagelocation US